package com.eshore.textanalyzer.elk.config;


import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xyd
 * @date 2021/5/10
 * ES配置类
 */
@Configuration
public class EsConfig {
    /**
     * 给容器注册一个 RestHighLevelClient,用来操作ES
     * 无密码
     * 官方文档 https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high.html
     * @return
     */
    @Bean
    public RestHighLevelClient restHighLevelClient() {
        return new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("xxxxxxxxxx",9200,"http")));
    }
}
